package src.model.gameWorld;

import src.event.*;
import src.event.events.*;

/**
 * <b>Overview</b><br>
 * <p>In order to pass messages form the contorller subsystem to the gameWorld
 * subsystem, a static communicaiotn line must in place</p>
 * <br><br>
 * <b>Responsibilites</b><br>
 * <p>initiate communication (event passing) between outside subsystems and 
 * the gameWorld subsystem.</p>
 * <br><br>
 * <b>Collaborators</b>
 * <ul>
 * <li>EventHandler<T> - Subcontractor</li>
 * </ul>
 * <br><br>
 * <b>Implementor</b> - Brent<br>
 * <b>Tester</b> - Tim<br>
 * 
 * @author Brent
 *
 */
public class ModelEventHandler {
	
	private static ModelEventHandler staticReference;
	
	private EventHandler<NextPlayer> nextPlayerEventHandler;
	private EventHandler<SelectNextUnit> selectNextUnitEventHandler;
	private EventHandler<SelectNextStructure> selectNextStructureEventHandler;
	private EventHandler<SelectPosition> selectPositionEventHandler;
	
	
	public ModelEventHandler()
	{
		staticReference = this;
		 
		nextPlayerEventHandler = new EventHandler<NextPlayer>();
		selectNextUnitEventHandler = new EventHandler<SelectNextUnit>();
		selectNextStructureEventHandler = new EventHandler<SelectNextStructure>();
		selectPositionEventHandler = new EventHandler<SelectPosition>();
	}
	
	EventHandler<NextPlayer> getNextPlayerEventHandler()
	{
		return nextPlayerEventHandler;
	}
	
	EventHandler<SelectNextUnit> getSelectNextUnitEventHandler()
	{
		return selectNextUnitEventHandler;
	}
	
	EventHandler<SelectNextStructure> getSelectNextStructureEventHandler()
	{
		return selectNextStructureEventHandler;
	}
	
	EventHandler<SelectPosition> getSelectPositionEventHandler()
	{
		return selectPositionEventHandler;
	}
	
	public static void registerNextPlayerListener(EventListener<NextPlayer> listener){
		staticReference.getNextPlayerEventHandler().regesterListener(listener);
	}

	public static void fireEvent(NextPlayer e)
	{
		staticReference.getNextPlayerEventHandler().fireEvent(e);
	}
	
	public static void fireEvent(SelectNextUnit e)
	{
		staticReference.getSelectNextUnitEventHandler().fireEvent(e);
	}
	
	public static void fireEvent(SelectNextStructure e)
	{
		staticReference.getSelectNextStructureEventHandler().fireEvent(e);
	}
	
	public static void fireEvent(SelectPosition e)
	{
		staticReference.getSelectPositionEventHandler().fireEvent(e);
	}
	
	public static boolean fireEventNow(NextPlayer e)
	{
		return staticReference.getNextPlayerEventHandler().fireEventNow(e);
	}
	
	public static boolean fireEventNow(SelectNextUnit e)
	{
		return staticReference.getSelectNextUnitEventHandler().fireEventNow(e);
	}
	
	public static boolean fireEventNow(SelectNextStructure e)
	{
		return staticReference.getSelectNextStructureEventHandler().fireEventNow(e);
	}
	
	public static boolean fireEventNow(SelectPosition e)
	{
		return staticReference.getSelectPositionEventHandler().fireEventNow(e);
	}
}
